package net.techwatch.contacts.server;

import java.util.ArrayList;
import java.util.List;

import net.techwatch.contacts.client.ContactService;
import net.techwatch.contacts.shared.Contact;


import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class ContactRemoteService extends RemoteServiceServlet implements
		ContactService {

	private static final List<Contact> CONTACTS = new ArrayList<Contact>();
	static {
		CONTACTS.add(new Contact("Fabrice", "Dewasmes", "fabrice.dewasmes@pragmaconsult.lu"));
		CONTACTS.add(new Contact("Mathieu", "Chatelain", "mathieu.chatelain@pragmaconsult.lu"));
		CONTACTS.add(new Contact("Gwendal", "Lepages", "gwendal.lepages@pragmaconsult.lu"));
	}
	
	@Override
	public void addContacts(Contact c) {
		CONTACTS.add(c);
	}

	@Override
	public void deleteContacts(List<Contact> contacts) {
		for(Contact c : contacts) {
			CONTACTS.remove(c);
		}
	}

	@Override
	public List<Contact> getAllContacts() {
		return CONTACTS;
	}

}
